package net.sx.minemodule.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import net.sx.minemodule.R;

public class ExpanListAdapter extends BaseExpandableListAdapter {
    private String[] groupString = {"提现无法到账？", "如何提现？", "积分如何使用？"};
    private String[][] childString = {{"请检查您当前账户和提现的账户是否一致请检查您当前账户和提现的账户是否一致请检查您当前账户和提现的账户是否一致请检查您当前账户和提现的账户是否一致请检查您当前账户和提现的账户是否一致"},
            {"如何提现？如何提现？如何提现？如何提现？如何提现？如何提现？如何提现？如何提现？如何提现？如何提现？如何提现？如何提现？如何提现？"},
            {"积分如何使用？积分如何使用？积分如何使用？积分如何使用？积分如何使用？积分如何使用？积分如何使用？积分如何使用？积分如何使用？积分如何使用？"}};

    @Override
    public int getGroupCount() {
        return groupString.length;
    }

    @Override
    public int getChildrenCount(int i) {
        return childString[i].length;
    }

    @Override
    public Object getGroup(int i) {
        return groupString[i];
    }

    @Override
    public Object getChild(int i, int i1) {
        return childString[i][i1];
    }

    @Override
    public long getGroupId(int i) {
        return i;
    }

    @Override
    public long getChildId(int i, int i1) {
        return i1;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
        GroupViewHodler groupViewHodler;
        if (view == null) {
            view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.mine_expan_parent_item, viewGroup, false);
            groupViewHodler = new GroupViewHodler();
            groupViewHodler.groupText = view.findViewById(R.id.group_text);
//            groupViewHodler.groupImg = view.findViewById(R.id.group_img);
            view.setTag(groupViewHodler);
        } else {
            groupViewHodler = (GroupViewHodler) view.getTag();
        }
        groupViewHodler.groupText.setText(groupString[i]);
//        groupViewHodler.groupImg.setImageResource(b ? R.mipmap.down : R.mipmap.up);
        return view;
    }

    @Override
    public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {
        ChildViewHolder childViewHolder;
        if (view == null) {
            view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.mine_expan_child_item, viewGroup, false);
            childViewHolder = new ChildViewHolder();
            childViewHolder.childText = view.findViewById(R.id.child_text);
            view.setTag(childViewHolder);
        } else {
            childViewHolder = (ChildViewHolder) view.getTag();
        }
        childViewHolder.childText.setText(childString[i][i1]);
        return view;
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
        return true;
    }

    public class GroupViewHodler{
        TextView groupText;
//        ImageView groupImg;
    }

    public class ChildViewHolder{
        TextView childText;
    }
}
